﻿using EasyNetQ.Topology;
using Mysoft.Common.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mysoft.Tasks.Queue.IService
{
    /// <summary>
    /// RabbitMQEventBus
    /// </summary>
    public interface IMQEventBus
    {
        /// <summary>
        /// 发消息
        /// </summary>
        /// <typeparam name="TMessage"></typeparam>
        /// <param name="message">消息体</param>
        /// <param name="exchange">交换机</param>
        /// <param name="routingKey">路由</param>
        /// <param name="type">消息类型</param>
        /// <returns></returns>
        void Publish<TMessage>(TMessage message, string exchange, string routingKey, string type = ExchangeType.Topic);
 
        /// <summary>
        /// 订阅消息
        /// </summary>
        /// <param name="eventType">消息体</param>
        /// <param name="type">消息类型</param>
        void Subscribe(Type eventType, string type = ExchangeType.Topic);


        /// <summary>
        /// 发延时消息
        /// </summary>
        /// <typeparam name="TMessage"></typeparam>
        /// <param name="message">消息体</param>
        /// <param name="query">延时队列</param>
        /// <param name="exchange">延时交换机</param>
        /// <param name="routingKey">延时路由</param>
        /// <param name="exchange">死信交换机</param>
        /// <param name="routingKey">死信路由</param>
        /// <param name="delay">延时时间（毫秒）</param>
        /// <param name="QueryType">队列消息延时类型</param>
        /// <param name="type">队列消息交换机模式</param>
        /// <returns></returns>
        void DelayedPublish<TMessage>(TMessage message, string queue, string exchange, string routingKey,string deadExchange,string deadRoutingKey,int delay, DeadQueryType QueryType = DeadQueryType.message, string type = ExchangeType.Topic);


        /// <summary>
        /// 获取消息队列使用的中间件
        /// </summary>
        string GetMode();
    }
}
